import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'

// 导入字体样式
import './assets/fonts/iconfont.css'
// 映入公共样式
import './assets/css/common.css'

// 导入axio
import axios from 'axios'

// 导入富文本编辑框
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

// 导入lodash组件 使用方法clonedeep
import _ from 'lodash'

// 导入tree-table组件
import treeTable from 'vue-table-with-tree-grid'
Vue.component('tree-table', treeTable)
// 导入富文本编辑框
Vue.use(VueQuillEditor)
Vue.prototype.$_ = _
// 配置axios请求头拦截
axios.interceptors.request.use(config => {
  // 每次请求得将缓存中的token值传过去
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
// 配置请求根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'

Vue.prototype.$http = axios
// 定义一个全局过滤器
Vue.filter('dateFormat', function (date) {
  var dt = new Date(date)
  var y = dt.getFullYear()
  var m = (dt.getMonth() + 1 + '').padStart(2, '0')
  var d = (dt.getDate() + ' ').padStart(2, '0')

  return `${y}-${m}-${d}`
})
Vue.config.productionTip = false
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
